package com.hundredapp.oa.repository;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.hundredapp.oa.dao.GenericDao;
import com.hundredapp.oa.domain.OaAction;
import com.hundredapp.oa.domain.OaReserve;

@Repository
public class ReserveManagerImpl implements ReserveManager {

	@Autowired
	private GenericDao<OaReserve, Integer> reserveDao;
	@Autowired
	private GenericDao<OaAction, Integer> actionDao;
	
	@Override
	public int add(OaReserve reserve) {
		return reserveDao.save(reserve);
	}

	public GenericDao<OaReserve, Integer> getReserveDao() {
		return reserveDao;
	}

	public void setReserveDao(GenericDao<OaReserve, Integer> reserveDao) {
		this.reserveDao = reserveDao;
	}

	public GenericDao<OaAction, Integer> getActionDao() {
		return actionDao;
	}

	public void setActionDao(GenericDao<OaAction, Integer> actionDao) {
		this.actionDao = actionDao;
	}

	@Override
	public List<OaReserve> findAllReserve(String condition,int start, int limit) {
		return reserveDao.find(condition,start, limit);
	}

	@Override
	public OaReserve findReserveById(int id) {
		return reserveDao.findById(id);
	}

	@Override
	public void delete(int id) {
		reserveDao.remove(reserveDao.findById(id));
	}

	@Override
	public void update(OaReserve reserve) {
		reserveDao.modify(reserve);
	}

	@Override
	public int count(String condition) {
		return reserveDao.count(condition);
	}

	@Override
	public List<OaReserve> findAll(String condition) {
		return reserveDao.find(condition);
	}

}
